//  Copyright (c) 2008  Yoong-ki Ahn & Youngjin Kim < mexif@googlegroups.com>
//  See the enclosed file COPYING for license information (MIT Licence).
//  If you did not receive this file,
//  see http://www.opensource.org/licenses/mit-license.php.

#define _MEXIFLIB_INSIDE
#include "mexiflib.h"
#include <memory.h>
#include <string.h>
#include <stdio.h>

#include "mexif_tagdb_exif.inl"
#include "mexif_tagdb_gps.inl"
#include "mexif_tagdb_interop.inl"

#include "mexif_tagdb_canon.inl"
#include "mexif_tagdb_casio1.inl"
#include "mexif_tagdb_casio2.inl"
#include "mexif_tagdb_fujifilm.inl"
#include "mexif_tagdb_minolta.inl"
#include "mexif_tagdb_nikon1.inl"
#include "mexif_tagdb_nikon2.inl"
#include "mexif_tagdb_olympus.inl"
#include "mexif_tagdb_panasonic1.inl"
#include "mexif_tagdb_pentax1.inl"
#include "mexif_tagdb_pentax2.inl"
#include "mexif_tagdb_ricoh.inl"
#include "mexif_tagdb_sanyo.inl"
#include "mexif_tagdb_sigma.inl"
#include "mexif_tagdb_sony.inl"


void MEXIF_API mexif_tagdb_init( mexif_tagdb_meta_t* meta, mexif_format_t format ) 
{
	switch( format )
	{
#define SET_META( x )	\
	meta->db = mexif_ ## x ## _db;	\
	meta->count = _MEXIF_TAGID_ ## x ## _Count;	\
	meta->func  = mexif_ ## x ## _search

#define CASE_MAKER( x )	case MEXIF_FORMAT_ ## x ## _IFD :	SET_META( x ) ; break

	CASE_MAKER( EXIF );
	CASE_MAKER( GPS  );
	CASE_MAKER( INTEROP );


// 	case MEXIF_FORMAT_EXIF_IFD :
// 		meta->db		= mexif_tagid_exif_db;
// 		meta->count     = _MEXIF_TAGID_EXIF_Count;
// 		meta->func      = mexif_tagid_EXIF_search;
// 		break;
// 
// 	case MEXIF_FORMAT_GPS_IFD :
// 		meta->db		= mexif_tagid_gps_db;
// 		meta->count     = _MEXIF_TAGID_GPS_Count;
// 		meta->func      = mexif_tagid_GPS_search;
// 		break;
// 
// 	case MEXIF_FORMAT_INTEROP_IFD :
// 		meta->db		= mexif_tagid_interop_db;
// 		meta->count     = _MEXIF_TAGID_INTEROP_Count;
// 		meta->func      = mexif_tagid_INTEROP_search;
// 		break;

	CASE_MAKER( CANON );
	CASE_MAKER( CASIO1 );
	CASE_MAKER( CASIO2 );
	CASE_MAKER( FUJIFILM );
	//CASE_MAKER( KONICA );
	CASE_MAKER( MINOLTA );
	CASE_MAKER( NIKON1 );
	CASE_MAKER( NIKON2 );
	CASE_MAKER( OLYMPUS );
	CASE_MAKER( PANASONIC1 );
	CASE_MAKER( PENTAX1 );
	CASE_MAKER( PENTAX2 );
	//CASE_MAKER( POLAROID );
	CASE_MAKER( RICOH );
	//CASE_MAKER( SAMSUNG );
	CASE_MAKER( SANYO );
	//CASE_MAKER( SHARP );
	CASE_MAKER( SIGMA );
	CASE_MAKER( SONY );
	//CASE_MAKER( TOSHIBA );



	case MEXIF_FORMAT_CANON_CameraSettings	: SET_META( CANON_CameraSettings	);	break;
	case MEXIF_FORMAT_CANON_FocalLength		: SET_META( CANON_FocalLength		);	break;
	case MEXIF_FORMAT_CANON_ShotInfo		: SET_META( CANON_ShotInfo			);	break;
	case MEXIF_FORMAT_CANON_Panorama		: SET_META( CANON_Panorama			);	break;
	case MEXIF_FORMAT_CANON_AFInfo			: SET_META( CANON_AFInfo			);	break;
	case MEXIF_FORMAT_CANON_MyColors		: SET_META( CANON_MyColors			);	break;
	case MEXIF_FORMAT_CANON_FaceDetect1		: SET_META( CANON_FaceDetect1		);	break;
	case MEXIF_FORMAT_CANON_FaceDetect2		: SET_META( CANON_FaceDetect2		);	break;
	case MEXIF_FORMAT_CANON_AFInfo2			: SET_META( CANON_AFInfo2			);	break;
	case MEXIF_FORMAT_CANON_FileInfo		: SET_META( CANON_FileInfo			);	break;
	case MEXIF_FORMAT_CANON_ProcessingInfo	: SET_META( CANON_ProcessingInfo	);	break;
	case MEXIF_FORMAT_CANON_SensorInfo		: SET_META( CANON_SensorInfo		);	break;
	case MEXIF_FORMAT_CANON_ColorInfo		: SET_META( CANON_ColorInfo			);	break;

	case MEXIF_FORMAT_MINOLTA_CameraSettings     : SET_META( MINOLTA_CameraSettings    ); break;
	case MEXIF_FORMAT_MINOLTA_CameraSettings7D   : SET_META( MINOLTA_CameraSettings7D  ); break;
	case MEXIF_FORMAT_MINOLTA_CameraSettings5D   : SET_META( MINOLTA_CameraSettings5D  ); break;
	case MEXIF_FORMAT_MINOLTA_CameraSettingsA100 : SET_META( MINOLTA_CameraSettingsA100); break;

	case MEXIF_FORMAT_NIKON1_PreviewImage	: SET_META( NIKON1_PreviewImage		);	break;
	case MEXIF_FORMAT_NIKON1_AFInfo			: SET_META( NIKON1_AFInfo			);	break;

	case MEXIF_FORMAT_OLYMPUS_Equipment			: SET_META( OLYMPUS_Equipment		); break;
	case MEXIF_FORMAT_OLYMPUS_CameraSettings	: SET_META( OLYMPUS_CameraSettings	); break;
	case MEXIF_FORMAT_OLYMPUS_FocusInfo			: SET_META( OLYMPUS_FocusInfo		); break;

	case MEXIF_FORMAT_PENTAX1_ShakeReductionInfo :	SET_META( PENTAX1_ShakeReductionInfo	);	break;
	case MEXIF_FORMAT_PENTAX1_ShotInfo :			SET_META( PENTAX1_ShotInfo				);	break;

	default :
		MEXIF_ASSERT( 0 );
		memset( meta, 0, sizeof(*meta) );
	}
}

